﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ASPNETPerformance._04_PageFilter {
    public partial class WhitespaceFilter : System.Web.UI.Page {
        protected void Page_Load( object sender, EventArgs e ) {
            if ( !this.Page.IsPostBack )
            {
                RawContents.Text = File.ReadAllText( Server.MapPath( "~/04_PageFilter/WhitespaceFilterDemo.aspx" ) );
                BytesInRawContent.Text = RawContents.Text.Length.ToString( "N0" );

                WebClient wc = new WebClient();
                string url = Request.Url.AbsoluteUri.ToLower().Replace( "whitespacefilter.aspx", "WhitespaceFilterDemo.aspx" );
                ViewSourceContents.Text = UTF8Encoding.UTF8.GetString( wc.DownloadData( url ) );
                BytesInViewSource.Text = ViewSourceContents.Text.Length.ToString( "N0" );
            }
        }
    }
}